/********************************************************************
        created:        2010/02/22
        filename:       htl_io_event.h
        author:         HongLiang

        purpose:    	event
*********************************************************************/
#ifndef __HTL_IO_EVENT_H__
#define __HTL_IO_EVENT_H_
#include "../container/htl_config.h"
__HTL_BEGIN_NAMESPACE
#define BV(x) (1 << x)
#define FDEVENT_IN     BV(0)
#define FDEVENT_PRI    BV(1)
#define FDEVENT_OUT    BV(2)
#define FDEVENT_ERR    BV(3)
#define FDEVENT_HUP    BV(4)
#define FDEVENT_NVAL   BV(5)
class ioevent {
public:
	typedef void (*call_handler)(ioevent* _this, int fd, int events, void* args);
public:
	virtual HTL_RESULT event_init(int _maxfds = 1024)=0;
	virtual HTL_RESULT event_add(int fd, int events)=0;
	virtual HTL_RESULT event_mod(int fd, int events)=0;
	virtual HTL_RESULT event_del(int fd)=0;
	virtual HTL_RESULT event_register(int fd, call_handler handler)=0;
	virtual HTL_RESULT event_unregister(int fd)=0;
	virtual HTL_RESULT event_poll(void* args, int timeout_ms)=0;
protected:
	ioevent() {}
public:
	virtual ~ioevent() {}
};
__HTL_END_NAMESPACE
#endif
